﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Windows.Forms;

namespace hpm
{
    class clsQuanHuyen
    {
        DAL da = new DAL();
        public DataTable dtbQuanHuyen;
        SqlCommand slqcom;
        SqlDataAdapter sqlDataAdapter = null;

        string _maQuan, _maTinh, _tenQuan;

        public string MaQuan { get; set; }
        public string MaTinh 
        {
            get
            {
                return this._maTinh;
            }
            set {this._maTinh = value; }
        }
        public string TenQuan { get; set; }

        public clsQuanHuyen()
        {
        }

        public DataTable getAllQuanHuyen()
        {
            da.ketnoiServer();
            dtbQuanHuyen = new DataTable();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select MaQuan, TenQuan from DMQuanHuyen order by TenQuan";
            this.slqcom.Connection = da.con;
            this.slqcom.CommandType = CommandType.Text;
            this.sqlDataAdapter = new SqlDataAdapter(this.slqcom);
            this.sqlDataAdapter.Fill(dtbQuanHuyen);
            //da.da_closeConnect();
            return dtbQuanHuyen;
        }


        public DataTable getQuanHuyenByTinh()
        {
            da.ketnoiServer();
            dtbQuanHuyen = new DataTable();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select MaQuan, TenQuan from DMQuanHuyen WHERE MaTinh = '"+ this._maTinh +"' order by TenQuan";
            this.slqcom.Connection = da.con;
            this.slqcom.CommandType = CommandType.Text;
            this.sqlDataAdapter = new SqlDataAdapter(this.slqcom);
            this.sqlDataAdapter.Fill(dtbQuanHuyen);
            //da.da_closeConnect();
            return dtbQuanHuyen;
        }
    }



}
